# !/usr/bin/env python
# coding=utf-8
# @Time    : 2018/7/14 14:18
# @Author  : 6imensiva
# @Site    : https://gitee.com/dimensiva/rpc_dao.git
# @File    : run.py
# @Software: PyCharm
# @Version: 2.7.
from thrift.transport import TSocket
from thrift.transport import TTransport
from thrift.protocol import TBinaryProtocol
from thrift.server import TServer
import DaoHandler
from idl_output.IDao import Processor
from configs import current_config


my_handler = DaoHandler.DaoHandler()
my_processor = Processor(my_handler)
my_transport = TSocket.TServerSocket('0.0.0.0', port=current_config.port)
transport_factory = TTransport.TBufferedTransportFactory()
protocol_factory = TBinaryProtocol.TBinaryProtocolFactory()
# my_server = TServer.TSimpleServer(my_processor, my_transport, transport_factory,
#                                   protocol_factory)
my_server = TServer.TThreadPoolServer(my_processor, my_transport, transport_factory,
                                      protocol_factory)


print('Starting the server...')
my_server.serve()
print('done.')

# public
#
#
# class Server {
#
# @ SuppressWarnings({"unchecked", "rawtypes"})
# private void start(int port) {
#
#
# try {
#
# TServerSocket serverTransport = new TServerSocket(port);
#
# ArithmeticService.Processor processor = new ArithmeticService.Processor(new ArithmeticServiceImpl());
#
# TServer server = new TThreadPoolServer(new TThreadPoolServer.Args(serverTransport).processor(processor));
# server.serve();
#
# } catch (TTransportException e) {
# e.printStackTrace();
# }
# }
#
# public
# static
# void
# main(String[]
# args) {
# new
# Server().start(8082);
# }
#
# }
#
# 作者：igool
# 链接：https: // www.jianshu.com / p / 57
# bd0c7ba347
# 來源：简书
# 简书著作权归作者所有，任何形式的转载都请联系作者获得授权并注明出处。